import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/auth/login',
    method: 'post',
    data: data
  })
}

export function updatePwd(data) {
  return request({
    url: '/sys/user/updatePwd',
    method: 'post',
    data: data
  })
}

export function getCode(params) {
  return request({
    url: '/auth/getCode',
    method: 'post',
    data: params
  })
}

export function logout() {
  return request({
    url: '/auth/logout',
    method: 'delete'
  })
}

export function getInfo(token) {
  return request({
    url: '/vue-admin-template/user/info',
    method: 'get',
    params: { token }
  })
}

export function getRoutes() {
  return request({
    url: '/auth/menu',
    method: 'post'
  })
}

export function getRoles(param) {
  return request({
    url: '/sys/role/query',
    method: 'post',
    data: param
  })
}

export function updateRole(param) {
  return request({
    url: '/sys/role/update',
    method: 'post',
    data: param
  })
}

export function addRole(param) {
  return request({
    url: '/sys/role/add',
    method: 'post',
    data: param
  })
}

export function getPermissionTree(param) {
  return request({
    url: '/sys/module/queryAll',
    method: 'post',
    data: param
  })
}

export function queryModule(param) {
  return request({
    url: '/sys/module/queryModule',
    method: 'post',
    data: param
  })
}

export function deleteRole(param) {
  return request({
    url: '/sys/role/del',
    method: 'post',
    data: param
  })
}

export function isRoleNameExist(param) {
  return request({
    url: '/sys/role/isNameExist',
    method: 'post',
    data: param
  })
}

export function getUsers(param) {
  return request({
    url: '/sys/user/query',
    method: 'post',
    data: param
  })
}

export function addUser(param) {
  return request({
    url: '/sys/user/add',
    method: 'post',
    data: param
  })
}

export function isUserNameExist(param) {
  return request({
    url: '/sys/user/isNameExist',
    method: 'post',
    data: param
  })
}

export function deleteUser(param) {
  return request({
    url: '/sys/user/del',
    method: 'post',
    data: param
  })
}

export function updateUser(param) {
  return request({
    url: '/sys/user/update',
    method: 'post',
    data: param
  })
}

export function getOrganizations(param) {
  return request({
    url: '/core/baseOrganization/query',
    method: 'post',
    data: param
  })
}
